package com.lgx.mobile.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lgx.common.exception.DataException;
import com.lgx.mobile.dao.IFriendDao;
import com.lgx.mobile.entity.Friend;
import com.lgx.mobile.service.IFriendService;

/**
 * 好友Service
 * 
 * @author xuyichen
 *
 */
@Service("friendService")
public class FriendService implements IFriendService {

	@Autowired
	private IFriendDao friendDao;

	public IFriendDao getFriendDao() {
		return friendDao;
	}

	public void setFriendDao(IFriendDao friendDao) {
		this.friendDao = friendDao;
	}

	@Transactional
	public Friend createFriend(Friend friend) throws DataException {
		return this.friendDao.createFriend(friend);
	}

	@Transactional
	public Friend updateFriend(Friend friend) throws DataException {
		return this.friendDao.updateFriend(friend);
	}

	@Transactional
	public void deleteFriend(Friend friend) throws DataException {
		this.friendDao.deleteFriend(friend);
	}

	@Transactional
	public void deleteFriendById(long id) throws DataException {
		this.friendDao.deleteFriendById(id);
	}

	public Friend findFriendById(long id) {
		return this.friendDao.findFriendById(id);
	}
	
	public Friend checkFriendExists(long onwerUserId,long friendUserId){
		return this.friendDao.checkFriendExists(onwerUserId,friendUserId);
	}
	
	public List<Friend> findFriendListByOnwerUserId(long onwerUserId){
		return this.friendDao.findFriendListByOnwerUserId(onwerUserId);
	}

	public List<Friend> findFriendList() {
		return this.friendDao.findFriendList();
	}
}
